#include<iostream>
using namespace std;
typedef long long LL;
const int N = 3e5 + 10, MOD = 1e9 + 7;
LL s[N];
int arr[N], w[N];
int n;
LL fun(int l, int r)
{
	return (s[r] - s[l - 1]) * w[r - l -1];	
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
		s[i] = (s[i - 1] + arr[i]) % MOD;
	}	
	for (int i = 1; i <= n; i++) {
		cin >> w[i];
	}
	LL ans = 0;
	//for (int i = 1; i <= n; i++) {
	//	ans += n * fun(i, i);
	//	ans %= MOD;
	//}
	LL dp = 0;
	for (int len = 1; len <= n; len++) {
		dp = (dp + s[n - len + 1] - s[len - 1] + MOD) % MOD;
		int temp = dp * w[len] % MOD;
		ans = (ans + temp) % MOD;
	}
	cout << ans << endl;
	return 0;
}
		